<%@page import="itsm.isperp.framework.core.context.ContextHolder"%>
<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = ContextHolder.getWebServerName(request);
%>
<script type="text/javascript" src="<%=basePath%>js/libs/jqmeter.min.js"></script>
<isperp:taskView>
	<jsp:body> 
<div clsss="box no-border">
	<div class="header">
		<h3>&nbsp;&nbsp;任务信息</h3>
	</div>
	<table class="form-table">
		<tbody>
			<tr>
				<td class="td1">任务编号：</td>
				<td class="td2">${detail.code }</td>
			</tr>
			<tr>
				<td class="td1">任务名称：</td>
				<td class="td2">${detail.name }</td>
			</tr>
			<tr>
				<td class="td1">项目名称：</td>
				<td class="td2">${detail.project_name }</td>
			</tr>
			<tr>
				<td class="td1">项目阶段：</td>
				<td class="td2">${detail.project_stage }</td>
			</tr>
			<tr>
				<td class="td1">优先级：</td>
				<td class="td2">${detail.priority }</td>
			</tr>
			<tr>
				<td class="td1">负责人：</td>
				<td class="td2">${detail.plan_principal_name }</td>
			</tr>

			<tr>
				<td class="td1">计划执行时间：</td>
				<td class="td2">${detail.plan_start_time}至${detail.plan_end_time}</td>
			</tr>
			<tr>
				<td class="td1">计划工时(h)：</td>
				<td class="td2">${detail.plan_times }</td>
			</tr>
			<tr>
				<td class="td1">任务目标：</td>
				<td class="td2">${detail.target }</td>
			</tr>
			<tr>
				<td class="td1">任务内容：</td>
				<td class="td2">${detail.content }</td>
			</tr>
			<tr>
				<td class="td1">交付标准：</td>
				<td class="td2">${detail.deliverables }</td>
			</tr>
		</tbody>
	</table>
</div>

<div clsss="box no-border">
	<div class="header">
		<h3>&nbsp;&nbsp;处理信息</h3>
	</div>
	<form:form id="taskHandleForm" commandName="model" cssClass="validate"
				action="task/task/save">
		<form:hidden path="id" />

		<table class="form-table">
			<tbody>
			     <c:if test="${not empty model.inspectTemplateDefId }">
				<tr>
					<td class="td1">巡检项：</td>
					<td class="td2" style="padding:0">
					   <isperp:inspectTemplate defId="${model.inspectTemplateDefId }"
									taskId="${model.id }"></isperp:inspectTemplate>
					</td>
				</tr>
				</c:if>
				<tr>
					<td class="td1">是否完成：</td>
					<td class="td2"><form:radiobutton value="1" path="finished"
									label="是" /> <form:radiobutton value="0" path="finished"
									label="否" />
					</td>
				</tr>
				<tr>
					<td class="td1">执行时间：</td>
					<td class="td2"><form:input path="actStartTime"
									type="dateTime" />
							~<form:input path="actEndTime" type="dateTime" />
					</td>
				</tr>
				<tr>
					<td class="td1">消耗工时(h)：</td>
					<td class="td2"><form:input path="actTimes" maxlength="10"
									cssClass="required number" />
					</td>
				</tr>
				<tr>
					<td class="td1">处理人：</td>
					<td class="td2"><form:hidden path="actPrincipalId" /> <isperp:departmentUser
									id="actPrincipalIdSelector"
									displayValue="${model.actPrincipalName }"
									valueControlId="actPrincipalId" name="actPrincipalName"></isperp:departmentUser>
					</td>
				</tr>
				<tr>
					<td class="td1">处理情况：</td>
					<td class="td2"><form:textarea path="handleDesc"
									cssClass="required" />
							</td>
				</tr>
								<tr style="display:none">
					<td class="td1">处理成本：</td>
					<td class="td2"><isperp:projCostAccountingEntry
									relationId="${model.id }" projectId="${model.projectId}"></isperp:projCostAccountingEntry>
					</td>
				</tr>
				<tr>
					<td class="td1">附件：</td>
					<td class="td2"><isperp:uploader sourceId="${model.id }"
									id="taskFiles"></isperp:uploader>
					</td>
				</tr>


			</tbody>
		</table>


	</form:form>
	<script type="text/javascript">
		var dispatchDate = '${detail.dispatch_date }';
		//alert(dispatchDate);
		var dipdate = strToDate(dispatchDate);
		//alert(dipdate);
		//alert(dipdate);
		var date1 = dipdate; //开始时间
		var date2 = new Date(); //结束时间

		var num = (date2 - date1) / (1000 * 3600);
		var result = num.toFixed(2);
		$("#actTimes").val(result);
		//alert(result);

		function strToDate(str) {
			var tempStrs = str.split(" ");
			var dateStrs = tempStrs[0].split("-");
			var year = parseInt(dateStrs[0], 10);
			var month = parseInt(dateStrs[1], 10) - 1;

			var day = parseInt(dateStrs[2], 10);

			var timeStrs = tempStrs[1].split(":");
			var hour = parseInt(timeStrs[0], 10);
			var minute = parseInt(timeStrs[1], 10);
			var second = parseInt(timeStrs[2], 10);
			//alert(year+":"+month+":"+day+":"+hour+":"+minute+":"+second);
			var date = new Date(year, month, day, hour, minute, second);
			return date;
		}
		$(function(){
		  
		});
	</script>
</div>


</jsp:body>
</isperp:taskView>


<isperp:buttonList>
	<isperp:processButtons businessKey="${model.id }"
		formId="taskHandleForm" processKey="taskProcess"
		processId="${model.processId }"></isperp:processButtons>
</isperp:buttonList>
